package grape.house.rest.estatenearbyfeature.mvc;

import com.baomidou.mybatisplus.core.metadata.IPage;
import grape.house.rest.estatenearbyfeature.form.EstateNearbyFeatureListForm;
import grape.house.service.estatenearbyfeature.query.EstateNearbyFeatureListQuery;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.validation.Valid;
import grape.house.rest.estatenearbyfeature.form.EstateNearbyFeatureCreateForm;
import grape.house.rest.estatenearbyfeature.form.EstateNearbyFeatureUpdateForm;
import grape.house.rest.estatenearbyfeature.form.EstateNearbyFeatureListPageForm;
import grape.house.rest.estatenearbyfeature.vo.EstateNearbyFeatureVo;
import grape.house.rest.estatenearbyfeature.mapper.EstateNearbyFeatureWebMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import grape.common.rest.mvc.BaseController;
import grape.house.service.estatenearbyfeature.po.EstateNearbyFeature;
import grape.house.service.estatenearbyfeature.api.IEstateNearbyFeatureService;
import java.util.List;
/**
 * <p>
 * 楼盘周边特色 前端控制器
 * </p>
 *
 * @author yangwei
 * @since 2020-09-22
 */
@RestController
@RequestMapping("/house/estatenearbyfeature")
@Api(tags = "楼盘周边特色相关接口")
public class EstateNearbyFeatureController extends BaseController<EstateNearbyFeatureVo, EstateNearbyFeature> {

    @Autowired
    private EstateNearbyFeatureWebMapper currentWebMapper;
    @Autowired
    private IEstateNearbyFeatureService currentService;



     @ApiOperation("添加楼盘周边特色")
     @PreAuthorize("hasAuthority('estatenearbyfeature:single:create')")
     @PostMapping
     @ResponseStatus(HttpStatus.CREATED)
     public EstateNearbyFeatureVo create(@RequestBody @Valid EstateNearbyFeatureCreateForm cf) {
         EstateNearbyFeature po = currentWebMapper.formToPo(cf);
         return super.create(po);
     }

     @ApiOperation("根据ID查询楼盘周边特色")
     @PreAuthorize("hasAuthority('estatenearbyfeature:single:queryById')")
     @GetMapping("/{id}")
     @ResponseStatus(HttpStatus.OK)
     public EstateNearbyFeatureVo queryById(@PathVariable String id) {
         return super.queryById(id);
     }

     @ApiOperation("删除楼盘周边特色")
     @PreAuthorize("hasAuthority('estatenearbyfeature:single:deleteById')")
     @DeleteMapping("/{id}")
     @ResponseStatus(HttpStatus.NO_CONTENT)
     public boolean deleteById(@PathVariable String id) {
         return super.deleteById(id);
     }

     @ApiOperation("更新楼盘周边特色")
     @PreAuthorize("hasAuthority('estatenearbyfeature:single:updateById')")
     @PutMapping("/{id}")
     @ResponseStatus(HttpStatus.CREATED)
     public EstateNearbyFeatureVo update(@PathVariable String id,@RequestBody @Valid EstateNearbyFeatureUpdateForm uf) {
         EstateNearbyFeature po = currentWebMapper.formToPo(uf);
         po.setId(id);
         return super.update(po);
     }

    @ApiOperation("不分页查询楼盘周边特色")
    @PreAuthorize("hasAuthority('estatenearbyfeature:single:list')")
    @GetMapping("/list")
    @ResponseStatus(HttpStatus.OK)
    public List<EstateNearbyFeatureVo> list(EstateNearbyFeatureListForm listForm) {
        EstateNearbyFeature po = currentWebMapper.formToPo(listForm);
        EstateNearbyFeatureListQuery estateNearbyFeatureListQuery = new EstateNearbyFeatureListQuery();
        estateNearbyFeatureListQuery.setPoQuery(po);
        return super.list(estateNearbyFeatureListQuery);
    }

    @ApiOperation("分页查询楼盘周边特色")
    @PreAuthorize("hasAuthority('estatenearbyfeature:single:listPage')")
    @GetMapping("/listPage")
    @ResponseStatus(HttpStatus.OK)
    public IPage<EstateNearbyFeatureVo> listPage(EstateNearbyFeatureListPageForm listPageForm) {
         EstateNearbyFeature po = currentWebMapper.formToPo(listPageForm);
        EstateNearbyFeatureListQuery estateNearbyFeatureListQuery = new EstateNearbyFeatureListQuery();
        estateNearbyFeatureListQuery.setPoQuery(po);
         return super.listPage(estateNearbyFeatureListQuery,listPageForm);
     }

}
